home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / perl5 / Text::Soundex.z / Text::Soundex
Encoding:
Text File  |  2002-10-03  |  3.9 KB  |  133 lines

  1.  
  2.  
  3.  
  4. TTTTeeeexxxxtttt::::::::SSSSoooouuuunnnnddddeeeexxxx((((3333))))                                              TTTTeeeexxxxtttt::::::::SSSSoooouuuunnnnddddeeeexxxx((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      Text::Soundex - Implementation of the Soundex Algorithm as Described by
  10.      Knuth
  11.  
  12. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.        use Text::Soundex;
  14.  
  15.        $code = soundex $string;            # get soundex code for a string
  16.        @codes = soundex @list;             # get list of codes for list of strings
  17.  
  18.        # set value to be returned for strings without soundex code
  19.  
  20.        $soundex_nocode = 'Z000';
  21.  
  22.  
  23. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  24.      This module implements the soundex algorithm as described by Donald Knuth
  25.      in Volume 3 of TTTThhhheeee AAAArrrrtttt ooooffff CCCCoooommmmppppuuuutttteeeerrrr PPPPrrrrooooggggrrrraaaammmmmmmmiiiinnnngggg.  The algorithm is
  26.      intended to hash words (in particular surnames) into a small space using
  27.      a simple model which approximates the sound of the word when spoken by an
  28.      English speaker.  Each word is reduced to a four character string, the
  29.      first character being an upper case letter and the remaining three being
  30.      digits.
  31.  
  32.      If there is no soundex code representation for a string then the value of
  33.      $soundex_nocode is returned.  This is initially set to undef, but many
  34.      people seem to prefer an _u_n_l_i_k_e_l_y value like Z000 (how unlikely this is
  35.      depends on the data set being dealt with.)  Any value can be assigned to
  36.      $soundex_nocode.
  37.  
  38.      In scalar context soundex returns the soundex code of its first argument,
  39.      and in array context a list is returned in which each element is the
  40.      soundex code for the corresponding argument passed to soundex e.g.
  41.  
  42.        @codes = soundex qw(Mike Stok);
  43.  
  44.      leaves @codes containing ('M200', 'S320').
  45.  
  46. EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  47.      Knuth's examples of various names and the soundex codes they map to are
  48.      listed below:
  49.  
  50.        Euler, Ellery -> E460
  51.        Gauss, Ghosh -> G200
  52.        Hilbert, Heilbronn -> H416
  53.        Knuth, Kant -> K530
  54.        Lloyd, Ladd -> L300
  55.        Lukasiewicz, Lissajous -> L222
  56.  
  57.      so:
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. TTTTeeeexxxxtttt::::::::SSSSoooouuuunnnnddddeeeexxxx((((3333))))                                              TTTTeeeexxxxtttt::::::::SSSSoooouuuunnnnddddeeeexxxx((((3333))))
  71.  
  72.  
  73.  
  74.        $code = soundex 'Knuth';              # $code contains 'K530'
  75.        @list = soundex qw(Lloyd Gauss);      # @list contains 'L300', 'G200'
  76.  
  77.  
  78. LLLLIIIIMMMMIIIITTTTAAAATTTTIIIIOOOONNNNSSSS
  79.      As the soundex algorithm was originally used a lllloooonnnngggg time ago in the US it
  80.      considers only the English alphabet and pronunciation.
  81.  
  82.      As it is mapping a large space (arbitrary length strings) onto a small
  83.      space (single letter plus 3 digits) no inference can be made about the
  84.      similarity of two strings which end up with the same soundex code.  For
  85.      example, both Hilbert and Heilbronn end up with a soundex code of H416.
  86.  
  87. AAAAUUUUTTTTHHHHOOOORRRR
  88.      This code was implemented by Mike Stok (stok@cybercom.net) from the
  89.      description given by Knuth.  Ian Phillips (ian@pipex.net) and Rich Pinder
  90.      (rpinder@hsc.usc.edu) supplied ideas and spotted mistakes.
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.